package com.ymatou.iapi.trading.sellerquery.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.seller.trading.api.parameter.Convertor;
import com.ymatou.query.seller.trading.api.parameter.ExportOrderInfo;
import com.ymatou.query.seller.trading.api.parameter.ExportSellerProductInfosBean;
import com.ymatou.query.seller.trading.api.parameter.ExportSellerProductInfosResponse;
import com.ymatou.query.seller.trading.api.parameter.GetExportProductInfoResult;
import com.ymatou.query.seller.trading.api.parameter.SellerExportOrderQueryModel;
import com.ymatou.query.seller.trading.api.parameter.SellerExportedProductInfo;
import com.ymatou.query.seller.trading.api.parameter.Sp_GetExportProductInfoByOrderIds_v1;
import com.ymatou.query.seller.trading.api.parameter.TimeRange;
import com.ymatou.query.seller.trading.api.parameter.Ymt_O_OrderNote;
import com.ymatou.query.seller.trading.api.parameter.Ymt_Order;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderInfo;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderState;
import com.ymatou.query.trading.api.parameter.GetExportProductInfo;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymttest.common.enums.LogisticsTypeEnum;
import com.ymttest.common.enums.OrderStatusEnum;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;

/**
 * @date 2016-06-28
 * @author songyefeng
 * @desc 分批导出卖家订单信息
 */
@TestSuite
public class Ts_ExportSellerProductInfos {

	private static ExportSellerProductInfosBean exportSellerProductInfosBean;
	private static com.ymatou.query.seller.trading.api.service.ExportSellerProductInfosCall exportSellerProductInfosCall;
//	private static com.ymatou.iapi.trading.sellerquery.service.ExportSellerProductInfosCall exportSellerProductInfosCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("分批导出卖家订单信息");
	}

	@Before
	public void caseUp() {
		exportSellerProductInfosBean = new ExportSellerProductInfosBean();
		exportSellerProductInfosCall = new com.ymatou.query.seller.trading.api.service.ExportSellerProductInfosCall();
//		exportSellerProductInfosCall = new com.ymatou.iapi.trading.sellerquery.service.ExportSellerProductInfosCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(exportSellerProductInfosCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private SellerExportedProductInfo fetchEquals(
			SellerExportedProductInfo expect,
			List<SellerExportedProductInfo> actuals) {
		if (DataUtil.isNullOrEmpty(actuals)) {
			return null;
		}
		int expOrderNo = expect.getOrderNo();
		int expProductNum = expect.getProductNum();
		BigDecimal expProductPrice = expect.getProductPrice();
		String expProductnames = expect.getProductNames();
		String expCatalogInfos = expect.getCatalogInfos();
		for (SellerExportedProductInfo actual : actuals) {
			if (expOrderNo == actual.getOrderNo()
					&& expProductNum == actual.getProductNum()
					&& expProductnames.equals(actual.getProductNames())
					&& expCatalogInfos.equals(actual.getCatalogInfos())) {
				if (null == expProductPrice || null == actual.getProductPrice()) {
					if (expProductPrice == actual.getProductPrice()) {
						return actual;
					}
				} else {
					if (expProductPrice.equals(actual.getProductPrice())) {
						return actual;
					}
				}
			}
		}
		return null;
	}

	private void verify() {
		ExportSellerProductInfosResponse expectedResponse = new ExportSellerProductInfosResponse();
		ConstructResponse(expectedResponse);
		ExportSellerProductInfosResponse actualResponse = exportSellerProductInfosCall
				.getExportSellerProductInfosResponse();
		DataUtil.verifyEquals(expectedResponse
				.getSellerExportedPartialProductInfos().size(), actualResponse
				.getSellerExportedPartialProductInfos().size(),
				"验证SellerExportedPartialProductInfos的数量");
		if (DataUtil.isNullOrEmpty(expectedResponse
				.getSellerExportedPartialProductInfos()) == false) {
			List<SellerExportedProductInfo> expects = expectedResponse
					.getSellerExportedPartialProductInfos();
			List<SellerExportedProductInfo> actuals = actualResponse
					.getSellerExportedPartialProductInfos();
			for (SellerExportedProductInfo expect : actuals) {
				int expOrderNo = expect.getOrderNo();
				int expProductNum = expect.getProductNum();
				BigDecimal expProductPrice = expect.getProductPrice();
				SellerExportedProductInfo actual = fetchEquals(expect, actuals);
				// boolean exists = actuals.stream().anyMatch(
				// x -> x.getOrderNo() == expOrderNo
				// && x.getProductNum() == expProductNum
				// && x.getProductPrice().equals(expProductPrice));
				boolean exists = actual == null ? false : true;
				DataUtil.verifyEquals(true, exists,
						"验证orderno:" + expect.getOrderNo() + "是否存在");

				if (exists) {
					// SellerExportedProductInfo actual = expects
					// .stream()
					// .filter(x -> x.getOrderNo() == expOrderNo
					// && x.getProductNum() == expProductNum
					// && x.getProductPrice().equals(
					// expProductPrice))
					// .collect(Collectors.toList()).get(0);
					DataUtil.verifyEquals(expect.getAddress(),
							actual.getAddress(),
							"验证orderno:" + actual.getOrderNo() + "的Address");
					DataUtil.verifyDateEquals(expect.getAddTime(),
							actual.getAddTime(),
							"验证orderno:" + actual.getOrderNo() + "的AddTime");
					DataUtil.verifyDateEquals(expect.getApplyPostPayTime(),
							actual.getApplyPostPayTime(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ApplyPostPayTime");
					DataUtil.verifyEquals(expect.getBuyerLoginId(),
							actual.getBuyerLoginId(),
							"验证orderno:" + actual.getOrderNo()
									+ "的BuyerLoginId");
					DataUtil.verifyDecimalEquals(expect.getCashAmount(),
							actual.getCashAmount(),
							"验证orderno:" + actual.getOrderNo() + "的CashAmount");
					DataUtil.verifyEquals(expect.getCatalogInfos(),
							actual.getCatalogInfos(),
							"验证orderno:" + actual.getOrderNo()
									+ "的CatalogInfos");
					DataUtil.verifyDecimalEquals(expect.getDepositAmount(),
							actual.getDepositAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的DepositAmount");
					DataUtil.verifyDecimalEquals(expect.getFreight(),
							actual.getFreight(),
							"验证orderno:" + actual.getOrderNo() + "的Freight");
					DataUtil.verifyEquals(expect.getIsPaidInFull(),
							actual.getIsPaidInFull(),
							"验证orderno:" + actual.getOrderNo()
									+ "的IsPaidInFull");
					DataUtil.verifyEquals(expect.getLeaveWord(),
							actual.getLeaveWord(),
							"验证orderno:" + actual.getOrderNo() + "的LeaveWord");
					DataUtil.verifyEquals(expect.getOrderNote(),
							actual.getOrderNote(),
							"验证orderno:" + actual.getOrderNo() + "的OrderNote");
					DataUtil.verifyEquals(expect.getOrderState(),
							actual.getOrderState(),
							"验证orderno:" + actual.getOrderNo() + "的OrderState");
					// DataUtil.verifyEquals(expect.getOrderType(),
					// actual.getOrderType(),
					// "验证orderno:" + actual.getOrderNo() + "的OrderType");
					DataUtil.verifyEquals(
							expect.getPackageDelivery_DomesticDelivered(),
							actual.getPackageDelivery_DomesticDelivered(),
							"验证orderno:" + actual.getOrderNo()
									+ "的PackageDelivery_DomesticDelivered");
					DataUtil.verifyDateEquals(expect.getPayTime(),
							actual.getPayTime(),
							"验证orderno:" + actual.getOrderNo() + "的PayTime");
					DataUtil.verifyEquals(expect.getPhone(), actual.getPhone(),
							"验证orderno:" + actual.getOrderNo() + "的Phone");
					DataUtil.verifyEquals(expect.getPostCode(),
							actual.getPostCode(),
							"验证orderno:" + actual.getOrderNo() + "的PostCode");
					DataUtil.verifyDecimalEquals(expect.getPostPayAmount(),
							actual.getPostPayAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的PostPayAmount");
					DataUtil.verifyEquals(expect.getProductNames(),
							actual.getProductNames(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ProductNames");
					DataUtil.verifyEquals(expect.getProductNos(),
							actual.getProductNos(),
							"验证orderno:" + actual.getOrderNo() + "的ProductNos");
					DataUtil.verifyEquals(expect.getProductNum(),
							actual.getProductNum(),
							"验证orderno:" + actual.getOrderNo() + "的ProductNum");
					DataUtil.verifyDecimalEquals(expect.getProductPrice(),
							actual.getProductPrice(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ProductPrice");
					DataUtil.verifyEquals(expect.getReceivePerson(),
							actual.getReceivePerson(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ReceivePerson");
					DataUtil.verifyDecimalEquals(expect.getRefundAmount(),
							actual.getRefundAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的RefundAmount");
					DataUtil.verifyEquals(expect.getRemarkLevel(),
							actual.getRemarkLevel(),
							"验证orderno:" + actual.getOrderNo() + "的RemarkLevel");
					DataUtil.verifyEquals(expect.getRiskVerifiedStatus(),
							actual.getRiskVerifiedStatus(), "验证orderno:"
									+ actual.getOrderNo()
									+ "的RiskVerifiedStatus");
					DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
							.GetValueOrDefault(expect.getSellerCouponAmount()),
							actual.getSellerCouponAmount(), "验证orderno:"
									+ actual.getOrderNo()
									+ "的SellerCouponAmount");
					DataUtil.verifyEquals(expect.getTelephone(),
							actual.getTelephone(),
							"验证orderno:" + actual.getOrderNo() + "的Telephone");
					DataUtil.verifyDecimalEquals(expect.getTotalAmount(),
							actual.getTotalAmount(),
							"验证orderno:" + actual.getOrderNo() + "的TotalAmount");
				}
			}

		}
	}

	private void ConstructResponse(ExportSellerProductInfosResponse response) {
		Process(response);
	}

	private void Process(ExportSellerProductInfosResponse response) {
		SellerExportOrderQueryModel model = Convertor
				.SellerExportOrderRequestArguments(exportSellerProductInfosBean);
		ExportSellerProductInfosResponseProcessor(model, response);
	}

	@SuppressWarnings("rawtypes")
	private void ExportSellerProductInfosResponseProcessor(
			SellerExportOrderQueryModel model,
			ExportSellerProductInfosResponse response) {
		Sp_GetExportProductInfoByOrderIds_v1 sp = ExportOrderInfo
				.GetExportSellerProductInfoListSqlCommand(model);
		List<Map> orders = sp.getOrders();
		List<Map> orderInfos = sp.getOrderInfos();
		List<Map> orderNotes = sp.getOrderNotes();
		List<Map> orderStates = sp.getOrderStates();
		GetExportProductInfoResult result = ConvertResult(orders, orderInfos,
				orderNotes, orderStates);
		if (DataUtil.isNullOrEmpty(result.getOrders())) {
			response.setSellerExportedPartialProductInfos(new ArrayList<SellerExportedProductInfo>());
			response.setNextPartitionKey(null);
		}
		response.setNextPartitionKey(result.getOrders().size() < ExportOrderInfo.MAX_PER_QUERY_COUNT ? null
				: String.valueOf(result.getOrders().stream()
						.min((a, b) -> a.getiOrderId() - b.getiOrderId()).get()
						.getiOrderId()));
		response.setSellerExportedPartialProductInfos(GetExportProductInfo
				.GetExportProductInfos(result));
	}

	@SuppressWarnings("rawtypes")
	private GetExportProductInfoResult ConvertResult(List<Map> orders,
			List<Map> orderInfos, List<Map> orderNotes, List<Map> orderStates) {
		GetExportProductInfoResult result = new GetExportProductInfoResult();
		List<Ymt_Order> Orders = new ArrayList<Ymt_Order>();
		List<Ymt_OrderInfo> OrderInfos = new ArrayList<Ymt_OrderInfo>();
		List<Ymt_O_OrderNote> OrderNotes = new ArrayList<Ymt_O_OrderNote>();
		List<Ymt_OrderState> OrderStates = new ArrayList<Ymt_OrderState>();
		if (false == DataUtil.isNullOrEmpty(orders)) {
			for (Map m : orders) {
				Ymt_Order order = new Ymt_Order();
				DataUtil.mapToBean(order, m);
				Orders.add(order);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderInfos)) {
			for (Map m : orderInfos) {
				Ymt_OrderInfo oi = new Ymt_OrderInfo();
				DataUtil.mapToBean(oi, m);
				OrderInfos.add(oi);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderNotes)) {
			for (Map m : orderNotes) {
				Ymt_O_OrderNote note = new Ymt_O_OrderNote();
				DataUtil.mapToBean(note, m);
				OrderNotes.add(note);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderStates)) {
			for (Map m : orderStates) {
				Ymt_OrderState state = new Ymt_OrderState();
				DataUtil.mapToBean(state, m);
				OrderStates.add(state);
			}
		}
		result.setOrders(Orders);
		result.setOrderInfos(OrderInfos);
		result.setOrderNotes(OrderNotes);
		result.setOrderStates(OrderStates);
		return result;
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_001() {
		Logger.start(true, "分批导出卖家订单信息");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerProductInfosBean.setPaidTime(paidTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_002() {
		Logger.start(true, "分批导出卖家订单信息, 测试paidTime筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerProductInfosBean.setPaidTime(paidTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_003() {
		Logger.start(true, "分批导出卖家订单信息, 测试订单状态为17的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.SellerAccept.getValue());
			exportSellerProductInfosBean.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerProductInfosBean.setPaidTime(paidTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_004() {
		Logger.start(true, "分批导出卖家订单信息, paidTime的end为空");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			exportSellerProductInfosBean.setPaidTime(paidTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_005() {
		Logger.start(true, "分批导出卖家订单信息, paidTime的start为空");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange paidTime = new TimeRange();
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerProductInfosBean.setPaidTime(paidTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_006() {
		Logger.start(true, "分批导出卖家订单信息, 测试订单状态为101的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.OrderPostPay.getValue());
			exportSellerProductInfosBean.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-1));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0));
			exportSellerProductInfosBean.setPaidTime(paidTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_007() {
		Logger.start(true, "分批导出卖家订单信息, 测试BuyerNickName的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			exportSellerProductInfosBean.setBuyerNickName("lunchzhao");
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_008() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,begin+end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-1));
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0));
			exportSellerProductInfosBean.setCreatedTime(createdTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_009() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,只有begin");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-1));
			exportSellerProductInfosBean.setCreatedTime(createdTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_010() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,只有end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-3));
			exportSellerProductInfosBean.setCreatedTime(createdTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_011() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,begin+end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-5));
			deliveredTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-3));
			exportSellerProductInfosBean.setDeliveredTime(deliveredTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_012() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,只有begin");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-30));
			exportSellerProductInfosBean.setDeliveredTime(deliveredTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_013() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,只有end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-30));
			exportSellerProductInfosBean.setDeliveredTime(deliveredTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_ExportSellerProductInfos_014() {
		Logger.start(true, "分批导出卖家订单信息, 测试LogisticsTypes的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			List<Integer> logisticsTypes = new ArrayList<Integer>();
			logisticsTypes
					.add(LogisticsTypeEnum.XloboBondedDelivery.getValue());
			exportSellerProductInfosBean.setLogisticsTypes(logisticsTypes);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_015() {
		Logger.start(true, "分批导出卖家订单信息, 测试OrderId的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			exportSellerProductInfosBean.setOrderId(105836235);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_016() {
		Logger.start(true, "分批导出卖家订单信息, 测试OrderStatus的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.AccountPaid.getValue());
			orderStatus.add(OrderStatusEnum.OrderEstablish.getValue());
			exportSellerProductInfosBean.setOrderStatus(orderStatus);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_017() {
		Logger.start(true,
				"分批导出卖家订单信息, 测试PayTypes的筛选(ymt_orders.bShangouOrder)");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			List<Integer> payTypes = new ArrayList<Integer>();
			payTypes.add(0);
			payTypes.add(2);
			exportSellerProductInfosBean.setPayTypes(payTypes);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_018() {
		Logger.start(true,
				"分批导出卖家订单信息, 测试PostpayAppliedTime的筛选(ymt_orders.dApplyPostPayTime),begin+end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange postpayAppliedTime = new TimeRange();
			postpayAppliedTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			postpayAppliedTime.setEnd(YMTDateUtil.getBeforeOrNextDay(1));
			exportSellerProductInfosBean
					.setPostpayAppliedTime(postpayAppliedTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_019() {
		Logger.start(true,
				"分批导出卖家订单信息, 测试PostpayAppliedTime的筛选(ymt_orders.dApplyPostPayTime),只有begin");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange postpayAppliedTime = new TimeRange();
			postpayAppliedTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-300));
			exportSellerProductInfosBean
					.setPostpayAppliedTime(postpayAppliedTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_020() {
		Logger.start(true,
				"分批导出卖家订单信息, 测试PostpayAppliedTime的筛选(ymt_orders.dApplyPostPayTime),只有end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			TimeRange postpayAppliedTime = new TimeRange();
			postpayAppliedTime.setEnd(YMTDateUtil.getBeforeOrNextDay(3));
			exportSellerProductInfosBean
					.setPostpayAppliedTime(postpayAppliedTime);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_021() {
		Logger.start(true, "分批导出卖家订单信息, 测试ProductName的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			exportSellerProductInfosBean.setProductName("接口自动化测试Test");
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_022() {
		Logger.start(true, "分批导出卖家订单信息, orderstatus=1,2,101,16,17,3,4");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.OrderEstablish.getValue());
			orderStatus.add(OrderStatusEnum.AccountPaid.getValue());
			orderStatus.add(OrderStatusEnum.OrderPostPay.getValue());
			orderStatus.add(OrderStatusEnum.ApplyForPostPay.getValue());
			orderStatus.add(OrderStatusEnum.SellerAccept.getValue());
			orderStatus.add(OrderStatusEnum.Shipped.getValue());
			orderStatus.add(OrderStatusEnum.Received.getValue());
			exportSellerProductInfosBean.setOrderStatus(orderStatus);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-7));
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0));
			exportSellerProductInfosBean.setCreatedTime(createdTime);
			List<Integer> logisticsTypes = new ArrayList<Integer>();
			exportSellerProductInfosBean.setLogisticsTypes(logisticsTypes);
			List<Integer> payTypes = new ArrayList<Integer>();
			payTypes.add(0);
			payTypes.add(1);
			exportSellerProductInfosBean.setPayTypes(payTypes);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerProductInfos_023() {
		Logger.start(true, "分批导出卖家订单信息, orderstatus=1,2,101,16,17,3,4");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerProductInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.OrderEstablish.getValue());
			orderStatus.add(OrderStatusEnum.AccountPaid.getValue());
			orderStatus.add(OrderStatusEnum.OrderPostPay.getValue());
			orderStatus.add(OrderStatusEnum.ApplyForPostPay.getValue());
			orderStatus.add(OrderStatusEnum.SellerAccept.getValue());
			orderStatus.add(OrderStatusEnum.Shipped.getValue());
			orderStatus.add(OrderStatusEnum.Received.getValue());
			exportSellerProductInfosBean.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextMonth(-1));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0));
			exportSellerProductInfosBean.setPaidTime(paidTime);
			List<Integer> logisticsTypes = new ArrayList<Integer>();
			logisticsTypes.add(LogisticsTypeEnum.PackageDelivery.getValue());
			logisticsTypes.add(LogisticsTypeEnum.US.getValue());
			exportSellerProductInfosBean.setLogisticsTypes(logisticsTypes);
			List<Integer> payTypes = new ArrayList<Integer>();
			payTypes.add(0);
			payTypes.add(1);
			exportSellerProductInfosBean.setPayTypes(payTypes);
			exportSellerProductInfosCall.setData(exportSellerProductInfosBean);
			exportSellerProductInfosCall.callService();
			Logger.verifyEquals("200", exportSellerProductInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}